package com.zxc.judgeservice.mapper;


import com.zxc.judgeservice.codesandbox.CodeSandbox;
import com.zxc.judgeservice.startegy.DefaultJudgeStrategy;
import com.zxc.judgeservice.startegy.JavaJudgeStrategy;
import com.zxc.judgeservice.startegy.JudgeContext;
import com.zxc.judgeservice.startegy.JudgeStartegy;
import com.zxc.oj.model.codesandbox.JudgeInfo;
import com.zxc.oj.model.entity.QuestionSubmit;
import com.zxc.oj.model.enums.QuestionSubmitLanguageEnum;
import org.springframework.stereotype.Service;

@Service
public class JudgeManager {

    public JudgeInfo doJudge(JudgeContext judgeContext) {
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        JudgeStartegy judgeStartegy = new DefaultJudgeStrategy();
        if(questionSubmit.getLanguage().equals(QuestionSubmitLanguageEnum.JAVA)){
            judgeStartegy=new JavaJudgeStrategy();
        }
        return judgeStartegy.doJudge(judgeContext);

    }
}
